package com.bwie.controller;

import com.bwie.common.domain.Business;
import com.bwie.common.domain.Menu;
import com.bwie.common.result.PageResult;
import com.bwie.common.result.Result;
import com.bwie.service.TissueService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @className: TissueController
 * @Description: TODO
 * @version: v1.８.0
 * @author: GONGWENXUE
 * @date: 2025/10/22 10:26
 */
@CrossOrigin
@RestController
@RequestMapping("tissue")
public class TissueController {
    @Autowired
    TissueService tissueService;
    /**
     * 商机列表
     */
    @PostMapping("businessList")
    public Result<PageResult<Business>> businessList(@RequestBody Business business){
        PageHelper.startPage(business.getPageNum(),business.getPageSize());
        List<Business> businessList=tissueService.businessList(business);
        PageInfo<Business> businessPageInfo = new PageInfo<>(businessList);
        return PageResult.toResult(businessPageInfo.getTotal(),businessList);
    }
    /**
     * 新增组织
     */
    @PostMapping("addOrganization")
    public Result<Integer> addOrganization(@RequestBody Menu menu){
        Integer i=tissueService.addOrganization(menu);
        return Result.success(i);
    }
}
